/**
 * Copyright 2008 Matthew DeLambo
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.delambo.drool.interfaces;

/**
 * @author delambo
 * @param NODE type of pool node. "N" is supposed to be reserved for Number, so...
 * @param R type of pool node resource. 
 */
public interface Pool<NODE, R> {
    
    interface Factory<NODE, R> {
        Pool<NODE, R> create(String props);
    }
    
    /**
     * Returns a resource to the pool.
     * @param r resource to return.
     */
    public void returnResource(R r);
    
    /**
     * Gets the next available resource in the pool.
     * @return the next good resource in the pool; DNE - null.
     */
    public R getResource();
    
    /**
     * Shuts down pool and closes resources/nodes in pool.
     */
    public void closePool();
    
    /**
     * Prints the current state of the pool and its resources.
     * @param location location or info of where method is called from. 
     */
    public void printState(String location);
    
    /**
     * 
     */
    public void startPool();
    
}
